<!--
Copyright 2012 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!DOCTYPE html>

<html>
  <head>
    <style>
      #main {
        position: relative;
        width: 500px;
        height: 300px;
        top: 100px;
        left: 100px;
        border: 2px solid black;
      }
      .anim {
        position: absolute;
        width: 50px;
        height: 50px;
        top: 0px;
        left: 0px;
        border-radius: 50%;
        background-color: lightsteelblue;
      }
      #b {
        position: absolute;
        left: 225px;
        top: 125px;
        background-color: red;
      }
      .block {
        background-color: #E3CEF6;
        width: 50px;
        height: 50px;
      }
      #blockA {
        top: 0px;
        left: 450px;
        position: absolute;
      }
      #blockB {
        top: 250px;
        left: 0px;
        position: absolute;
      }
      .txt {
        width: 700px;
        position: relative;
      }
    </style>
  </head>
  <body>
    <div class="txt">The animation consists of ...
      <ul>
        <li>a circle which changes colour as it moves along the edges of the box
        <li>a red circle which moves towards all 4 corners and back to the
          center of the box
        <li>2 squares that rotate and move along the top and bottom edges of the
          box
      </ul>
    </div>

    <div id="main">
      <div class="anim" id="a"></div>
      <div class="block" id="blockA"></div>
      <div class="anim" id="b"></div>
      <div class="block" id="blockB"></div>
    </div>
    <script src="../web-animations.js"></script>
    <script>
      "use strict";
      var around1 = new Animation(document.querySelector("#a"), {left: "450px"},
          2);
      var around2 = new Animation(document.querySelector("#a"), [
        {"background-color": "lightsteelblue"},
        {"background-color": "red"},
        {"background-color": "green"},
        {"background-color": "lightsteelblue"},
      ], 8);
      var around3 = new Animation(document.querySelector("#a"), {top: "250px"},
          {startDelay: 2, duration: 2});
      var around4 = new Animation(document.querySelector("#a"), {left: "0px"},
          {startDelay: 4, duration: 2});
      var around5 = new Animation(document.querySelector("#a"), {top: "0px"},
          {startDelay: 6, duration: 2});
      var blueBallMove = new ParGroup(
          [around1, around2, around3, around4, around5],
          {iterationCount: 2, direction: "alternate", duration: 8});

      var redBallMove = new SeqGroup([
        new Animation(document.querySelector("#b"), {top: "0px", left: "0px"}, 2),
        new Animation(document.querySelector("#b"), {top: "125px", left: "225px"}, 2),
        new Animation(document.querySelector("#b"), {top: "0px", left: "450px"}, 2),
        new Animation(document.querySelector("#b"), {top: "125px", left: "225px"}, 2),
        new Animation(document.querySelector("#b"), {top: "250px", left: "450px"}, 2),
        new Animation(document.querySelector("#b"), {top: "125px", left: "225px"}, 2),
        new Animation(document.querySelector("#b"), {top: "250px", left: "0px"}, 2),
        new Animation(document.querySelector("#b"), {top: "125px", left: "225px"}, 2),
      ], {duration: 16});

      document.timeline.play(new ParGroup([blueBallMove, redBallMove]));

      var transformGroup = new ParGroup([
        new Animation(document.querySelector("#blockA"), [
          {transform: "translate(0px, 0px) rotate(0deg)"},
          {transform: "translate(-450px, 0px) rotate(180deg)"}
        ] , 4),
        new Animation(document.querySelector("#blockB"), [
          {transform: "translate(0px, 0px) rotate(0deg)"},
          {transform: "translate(450px, 0px) rotate(270deg)"}
        ] , 4),
      ]);
      document.timeline.play(transformGroup);
    </script>
  </body>
</html>
